from small one page howto to huge articles all in one place
 

search text in:





Poll
What does your sytem tell when running "ulimit -u"?








poll results

Last additions:
using iotop to find disk usage hogs

using iotop to find disk usage hogs

words:

887

views:

195522

userrating:

average rating: 1.7 (102 votes) (1=very good 6=terrible)


May 25th. 2007:
Words

486

Views

252011

why adblockers are bad


Workaround and fixes for the current Core Dump Handling vulnerability affected kernels

Workaround and fixes for the current Core Dump Handling vulnerability affected kernels

words:

161

views:

140870

userrating:

average rating: 1.4 (42 votes) (1=very good 6=terrible)


April, 26th. 2006:

Druckversion . pdf icon
You are here: System->Tips and Tricks

Using script

This tip shows you how to use script as a way to store or share everything printed during a terminal session. This can be a great way to remotely demonstrate command-line Linux to a less experienced user. Alternatively, it's a good way to keep a record of everything you do (or did) for a specific session.

First we'll look at keeping a record of everything. The can be done by just issuing the command script. The output of your session will be written to a file named typescript. If you want to specify a file other than the default, use script file where file is the name of the file storing the session.

Code Listing 1: Creating a script session

% script  
Script started, file is typescript  
% uptime  
 13:27:53 up 89 days,  3:50,  1 user,  load average: 0.27, 0.35, 0.29  
% uname -srvmpio  
Linux 2.4.20-gentoo-r4 #1 SMP Fri May 9 08:54:35 EDT 2003 i686 Intel(R) Xeon(TM)  
 CPU 2.00GHz GenuineIntel GNU/Linux  
% exit  
Script done, file is typescript

The session file can be reviewed later with a pager such as more, less, or cat.

Code Listing 2: Viewing a script session

% more typescript  
Script started on Wed Aug  6 13:27:47 2003  
% uptime  
 13:27:53 up 89 days,  3:50,  1 user,  load average: 0.27, 0.35, 0.29  
% uname -srvmpio  
Linux 2.4.20-gentoo-r4 #1 SMP Fri May 9 08:54:35 EDT 2003 i686 Intel(R) Xeon(TM)  
 CPU 2.00GHz GenuineIntel GNU/Linux  
% exit  
  
Script done on Wed Aug  6 13:28:01 2003

Now we'll look at sharing a terminal session. The easiest way to do this is combining script with mkfifo (which creates a named pipe). Note that you need to use the -f option (script -f) to flush output after each write. This way, the terminal can be written to by User A and viewed in (near) real time by User B.

Code Listing 3: User A's terminal

% mkfifo demo; script -f demo  
Script started, file is demo  
% echo 'Hello World'  
Hello World  
% exit  
Script done, file is demo  

Note: User A's terminal will wait for input until User B issues the cat command (or accesses the named pipe).

Code Listing 4: User B's terminal

% cat demo  
Script started on Wed Aug  6 13:48:51 2003  
% echo 'Hello World'  
Hello World  
% exit  
  
Script done on Wed Aug  6 13:49:04 2003

There are many other ways script could be used - hopefully this will give you some ideas to get you started.

From http://www.gentoo.org/news/en/gwn/20030811-newsletter.xml


rate this article:
current rating: average rating: 1.3 (63 votes) (1=very good 6=terrible)
Your rating:
Very good (1) Good (2) ok (3) average (4) bad (5) terrible (6)

back





Support us on Content Nation
rdf newsfeed | rss newsfeed | Atom newsfeed
- Powered by LeopardCMS - Running on Gentoo -
Copyright 2004-2020 Sascha Nitsch Unternehmensberatung GmbH
Valid XHTML1.1 : Valid CSS : buttonmaker
- Level Triple-A Conformance to Web Content Accessibility Guidelines 1.0 -
- Copyright and legal notices -
Time to create this page: 47.3 ms